package com.itheima.config;  
 2  
 3 import org.mybatis.spring.SqlSessionFactoryBean;  
 4 import org.mybatis.spring.mapper.MapperScannerConfigurer;  
 5 import org.springframework.beans.factory.annotation.Autowired;  
 6 import org.springframework.context.annotation.Bean;  
 7  
 8 import javax.sql.DataSource;  
 9  
 10 public class MyBatisConfig {  
 11 @Bean  
 12 public SqlSessionFactoryBean getSqlSessionFactoryBean(@Autowired DataSource dataSource) {  
 13 SqlSessionFactoryBean ssfb = new SqlSessionFactoryBean();  
 14 ssfb.setDataSource(dataSource);  
 15 return ssfb;  
 16 }  
 17 @Bean  
 18 public MapperScannerConfigurer getMapperScannerConfigurer() {  
 19 MapperScannerConfigurer msc = new MapperScannerConfigurer();  
 20 msc.setBasePackage("com.itheima.mapper");  
 21 return msc;  
 22 }  
 23 } 